#!/bin/sh
killall mlnet
sleep 2
date 072823002010.00

if [ -n "`pidof btpd`" ]; then
killall btpd
sleep 10
fi

if [ -d /tmp/hdd/volumes/HDD1 ];then
  export HOME=/tmp/hdd/volumes/HDD1
elif [ $(ls /tmp/usbmounts | wc -l) -gt 0 ];then
  USBDIR=$(ls -d /tmp/usbmounts|head -n 1)
  export HOME=$USBDIR
else
  exit
fi
export LC_ALL=en_US.UTF-8
rm $HOME/.mldonkey/*.tmp 2>/dev/null
rm $HOME/.mldonkey/downloads.ini.tmp 2>/dev/null
rm $HOME/.mldonkey/users.ini.tmp  2>/dev/null         
rm $HOME/.mldonkey/mlnet.log 2>/dev/null         
rm $HOME/.mldonkey/*.pid 2>/dev/null         
/opt/bin/mlnet -allowed_ips '0.0.0.0/0'&
sleep 8
ls
